package org.feng.config.mybatisplus;

import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
import org.feng.utils.UserUtil;

/**
 * @Author feng
 * @Date 2022/3/28 16:52
 * @Description TODO
 */
public class TenantConfig implements TenantLineHandler {
    @Override
    public Expression getTenantId() {
        return null==UserUtil.getTenantId() ? null :new LongValue(UserUtil.getTenantId());
    }

    /**
     * 租户id的字段
     * @return
     */
    @Override
    public String getTenantIdColumn() {
        return "tenant_id";
    }

    @Override
    public boolean ignoreTable(String tableName) {
        return UserUtil.getTenantId()==null||"sys_menu_role".equals(tableName);
    }
}
